home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!cs.utexas.edu!rutgers!aramis.rutgers.edu!dartagnan.rutgers.edu!mcgrew
- From: mcgrew@dartagnan.rutgers.edu (Charles Mcgrew)
- Newsgroups: comp.sources.sun
- Subject: v01i036: Ethernet tools for SunOS 3.X, Part01/02
- Message-ID: <Jun.21.13.53.14.1989.29064@dartagnan.rutgers.edu>
- Date: 21 Jun 89 17:53:17 GMT
- Organization: Rutgers Univ., New Brunswick, N.J.
- Lines: 2236
- Approved: mcgrew@aramis.rutgers.edu
-
- Submitted-by: budd@bu-it.bu.edu
- Posting-number: Volume 1, Issue 36
- Archive-name: ethertools-3.X/part01
-
- Please note: this will not compile under OS 4.0.X. As Phil put it,
- "4.0 SNIT is a different beast altogether!".
-
- Charles
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 2)."
- # Contents: COPYRIGHT MANIFEST Makefile README addrs.c ctp.h ctpd.c
- # dump.c ether-prot.h hetoea.c htoea.c iptoea.c mfgr.h mfgrs.c ns.c
- # pbytes.c petaddr.c petaddrm.c petmf.c pipaddr.c protocol.h
- # puthex.c samecount.c show.c tab.c terpri.c test-htoea.c xval.c
- # Wrapped by budd@buita on Sat Aug 13 01:14:38 1988
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f COPYRIGHT -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"COPYRIGHT\"
- else
- echo shar: Extracting \"COPYRIGHT\" \(500 characters\)
- sed "s/^X//" >COPYRIGHT <<'END_OF_COPYRIGHT'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- END_OF_COPYRIGHT
- if test 500 -ne `wc -c <COPYRIGHT`; then
- echo shar: \"COPYRIGHT\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f MANIFEST -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"MANIFEST\"
- else
- echo shar: Extracting \"MANIFEST\" \(1104 characters\)
- sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X COPYRIGHT 1
- X MANIFEST 1 This shipping list
- X Makefile 1
- X README 1
- X addrs.c 1
- X ctp.c 2
- X ctp.h 1
- X ctpd.c 1
- X dump.c 1
- X ether-prot.h 1
- X hetoea.c 1
- X htoea.c 1
- X if_ctp.c 2
- X iptoea.c 1
- X mfgr.h 1
- X mfgrs.c 1
- X nit.c 2
- X ns.c 1
- X packet.h 2
- X pbytes.c 1
- X petaddr.c 1
- X petaddrm.c 1
- X petmf.c 1
- X pipaddr.c 1
- X protocol.h 1
- X puthex.c 1
- X rlog.c 2
- X samecount.c 1
- X show.c 1
- X tab.c 1
- X terpri.c 1
- X test-htoea.c 1
- X xval.c 1
- END_OF_MANIFEST
- if test 1104 -ne `wc -c <MANIFEST`; then
- echo shar: \"MANIFEST\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f Makefile -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"Makefile\"
- else
- echo shar: Extracting \"Makefile\" \(2770 characters\)
- sed "s/^X//" >Makefile <<'END_OF_Makefile'
- X# Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X# All Rights Reserved
- X
- X# Permission is granted to any individual or institution to use, copy,
- X# or redistribute this software so long as it is not sold for profit,
- X# provided that this notice and the original copyright notices are
- X# retained. Boston University makes no representations about the
- X# suitability of this software for any purpose. It is provided "as is"
- X# without express or implied warranty.
- X
- XCFLAGS=-g
- X
- XALL=ctp show ctpd htoea dump rlog tab addrs samecount
- Xall: $(ALL)
- X
- X# if_ctp.c is a kernel level CTP server
- X
- XLIB=lib.a
- XLIBFILES=ns.o mfgrs.o terpri.o pipaddr.o xval.o htoea.o hetoea.o iptoea.o \
- X nit.o puthex.o pbytes.o petaddr.o petmf.o petaddrm.o
- X
- X$(LIB): $(LIBFILES)
- X ar r $(LIB) $(LIBFILES)
- X ranlib lib.a
- X
- X# ctp client (like ping)
- XCTP=ctp.o $(LIB)
- Xctp: $(CTP)
- X $(CC) $(CFLAGS) -o ctp $(CTP)
- X
- X# user mode ctp server
- XCTPD=ctpd.o $(LIB)
- Xctpd: $(CTPD)
- X $(CC) $(CFLAGS) -o ctpd $(CTPD)
- X
- X# watch CTP traffic
- XSHOW=show.o $(LIB)
- Xshow: $(SHOW)
- X $(CC) $(CFLAGS) -o show $(SHOW)
- X
- X# dump traffic
- XDUMP=dump.o $(LIB)
- Xdump: $(DUMP)
- X $(CC) $(CFLAGS) -o dump $(DUMP)
- X
- X# convert hosts to ether addresses (test for my library routine)
- XHTOEA=test-htoea.o lib.a
- Xhtoea: $(HTOEA)
- X $(CC) $(CFLAGS) -o htoea $(HTOEA)
- X
- X################################################################
- X
- X# read log -- a packet printer
- XRLOG=rlog.o $(LIB)
- Xrlog: $(RLOG)
- X $(CC) $(CFLAGS) -o rlog $(RLOG)
- X
- X# tabulate information
- XTAB=tab.o $(LIB)
- Xtab: $(TAB)
- X $(CC) $(CFLAGS) -o tab $(TAB)
- X
- X# read log, print address pairs
- XADDRS=addrs.o $(LIB)
- Xaddrs: $(ADDRS)
- X $(CC) $(CFLAGS) -o addrs $(ADDRS)
- X
- X# count identical lines (ie; dump | addrs | sort | samecount)
- Xsamecount: samecount.c
- X $(CC) $(CFLAGS) -o samecount samecount.c
- X
- Xclean:
- X rm -f *.o $(ALL) ether.h core *~ \#*
- X
- Xshar:
- X shar README COPYRIGHT Makefile *.c *.h > shar
- X
- Xkit:
- X makekit -oMANIFEST README COPYRIGHT Makefile *.c *.h
- X
- Xdepend:
- X grep '^#[ ]*include' *.c | grep -v '<' | \
- X sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' \
- X -e 's/\.c/.o/' \
- X -e 's,../[a-zA-Z]*/,,' | \
- X awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \
- X else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
- X else rec = rec " " $$2 } } \
- X END { print rec } ' > makedep
- X echo '$$r makedep' >>eddep
- X echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
- X echo '$$r makedep' >>eddep
- X echo 'w' >>eddep
- X cp Makefile Makefile.bak
- X ed - Makefile < eddep
- X rm eddep makedep
- X
- X# DO NOT DELETE THIS LINE
- X
- Xaddrs.o: packet.h
- Xctp.o: ctp.h
- Xctpd.o: ctp.h
- Xif_ctp.o: ether.h param.h systm.h mbuf.h socket.h time.h kernel.h errno.h
- Xif_ctp.o: ioctl.h if.h in.h if_ether.h
- Xmfgrs.o: mfgr.h
- Xpetmf.o: mfgr.h
- Xpipaddr.o: packet.h
- Xrlog.o: packet.h protocol.h
- Xshow.o: ctp.h
- Xtab.o: packet.h
- END_OF_Makefile
- if test 2770 -ne `wc -c <Makefile`; then
- echo shar: \"Makefile\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f README -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"README\"
- else
- echo shar: Extracting \"README\" \(1407 characters\)
- sed "s/^X//" >README <<'END_OF_README'
- XCopyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- XAll Rights Reserved
- X
- XPermission is granted to any individual or institution to use, copy,
- Xor redistribute this software so long as it is not sold for profit,
- Xprovided that this notice and the original copyright notices are
- Xretained. Boston University makes no representations about the
- Xsuitability of this software for any purpose. It is provided "as is"
- Xwithout express or implied warranty.
- X
- X****************************************************************
- X
- XThis is a set of tools for access to raw ethernet on Suns. The only
- XSun dependant file is nit.c which contains the actual code to call NIT
- Xon Sun 3.x systems.
- X
- Xctp
- X Is a CTP client. It sends Ethernet Version 2 Configuration
- X Test protocol packets. Multiple hosts/addresses will send out
- X a packet to be forwarded thru that path. The last entry in
- X the packet is a 'reply' back to us.
- X
- X Has many options and a usage message.
- X
- X
- Xctpd
- X Is a user mode CTP daemon.
- X
- Xif_ctpd.c
- X Is a kernel mode CTP daemon.
- X
- Xshow
- X Watches all CTP traffic.
- X
- Xhtoea
- X Converts hosts to ether addresses.
- X
- Xdump
- X Dumps ether traffic (no filtering)
- X
- Xrlog
- X Reads and interprets a log written by dump
- X
- Xtab
- X Tablate sources, dests, protocols, lengths from a log.
- X
- Xaddrs
- X Print address pairs, proto, len etc.
- X
- Xsamecount
- X For use as:
- X
- X dump -c nnn | addrs | sort | samecount
- X
- X to get address pair counts.
- X
- END_OF_README
- if test 1407 -ne `wc -c <README`; then
- echo shar: \"README\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f addrs.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"addrs.c\"
- else
- echo shar: Extracting \"addrs.c\" \(2218 characters\)
- sed "s/^X//" >addrs.c <<'END_OF_addrs.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X# include <ctype.h>
- X# include "packet.h"
- X
- Xstruct hent {
- X union {
- X EA hd_ea;
- X short hd_type;
- X } h_data;
- X int h_cnt;
- X int h_inuse;
- X};
- X# define h_ea h_data.hd_ea
- X# define h_type h_data.hd_type
- X
- Xint length[ 1520 ];
- X
- Xint count = 0;
- Xint pc;
- Xint sflg, dflg, pflg;
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X extern char *optarg;
- X extern int optind, opterr;
- X int errs, c;
- X char line[ 4096 ];
- X register byte *pp;
- X register char *lp;
- X register int i;
- X
- X errs = 0;
- X sflg = dflg = pflg = 0;
- X while( (c = getopt( argc, argv, "sdp" )) != EOF ) {
- X switch( c ) {
- X case 's':
- X sflg++;
- X break;
- X case 'd':
- X dflg++;
- X break;
- X case 'p':
- X pflg++;
- X break;
- X default:
- X errs++;
- X }
- X }
- X if( errs > 0 )
- X exit( 1 );
- X
- X if( sflg + dflg + pflg == 0 )
- X sflg = dflg = pflg = 1;
- X
- X pc = 0;
- X pp = packet.p_bytes;
- X while( gets( line ) ) {
- X if( line[0] == ' ' || line[0] == '*' || line[0] == '\0' ) {
- X if( pc > 0 )
- X process();
- X pp = packet.p_bytes;
- X pc = 0;
- X continue;
- X }
- X
- X for( lp = line; *lp; lp++ ) {
- X if( isspace( *lp ) )
- X continue;
- X else if( isxdigit( *lp ) && isxdigit( lp[1] ) ) {
- X *pp++ = xval( *lp, lp[1] );
- X lp++;
- X pc++;
- X }
- X else
- X fprintf( stderr, "you lose: %s\n", lp );
- X }
- X }
- X if( pc > 0 )
- X process();
- X}
- X
- Xprocess() {
- X register struct etherpacket *e = (struct etherpacket *) &packet;
- X u_short type;
- X
- X count++;
- X type = packet.p_ether.e_type;
- X if( sflg ) {
- X petaddr( e->e_src );
- X putchar(' ');
- X }
- X if( dflg ) {
- X petaddr( e->e_dst );
- X putchar(' ');
- X }
- X if( pflg ) {
- X puthex( (type >> 8) & 0xff );
- X putchar( '-' );
- X puthex( type & 255 );
- X }
- X /* pc == len */
- X}
- END_OF_addrs.c
- if test 2218 -ne `wc -c <addrs.c`; then
- echo shar: \"addrs.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f ctp.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"ctp.h\"
- else
- echo shar: Extracting \"ctp.h\" \(1268 characters\)
- sed "s/^X//" >ctp.h <<'END_OF_ctp.h'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X/*
- X * Parameters for Ethernet Version 2
- X * Configuration Test Protocol
- X *
- X * Philip Budne @ BU/DSG
- X */
- X
- X# define ETHERTYPE_CTP 0x9000
- X
- X# define etcmp(a,b) (((*( (u_long *)a )) == (*((u_long *)b))) && \
- X ((*( (u_short *)&a[4] )) == (*((u_short *)&b[4]))))
- X
- Xstatic u_char bcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* broadcast */
- Xstatic u_char mcast[] = { 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* CTP mcast */
- X
- X# define CTP_REP 1
- X# define CTP_FWD 2
- X
- X# if defined(vax) || defined(ns32000)
- X# define CTP_SHORT(sp) (*(u_short *)(sp))
- X# define SSWAP(s) (s)
- X# else /* not defined(vax) || defined(ns32000) */
- X# define CTP_SHORT(sp) (*sp | (sp[1]<<8))
- X# define SSWAP(s) ((((s)>>8) & 0xff) | (((s)<<8) & 0xff00))
- X# endif /* not defined(vax) || defined(ns32000) */
- END_OF_ctp.h
- if test 1268 -ne `wc -c <ctp.h`; then
- echo shar: \"ctp.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f ctpd.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"ctpd.c\"
- else
- echo shar: Extracting \"ctpd.c\" \(3465 characters\)
- sed "s/^X//" >ctpd.c <<'END_OF_ctpd.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <sys/ioctl.h> /* TIOCNOTTY */
- X# include <sys/types.h>
- X# include <sys/time.h>
- X# include <net/nit.h>
- X# include <stdio.h>
- X# include "ctp.h"
- X
- Xstruct packet {
- X u_char p_dst[ 6 ];
- X u_char p_src[ 6 ];
- X u_short p_type;
- X u_char p_data[ 2048 ];
- X};
- X
- Xu_char localaddr[ 6 ];
- Xint debug = 0;
- Xchar *interface = "ie0";
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X extern char *optarg;
- X extern int optind, opterr;
- X int s, c, errs;
- X void nit_input(); /* forward */
- X
- X errs = 0;
- X while( (c = getopt( argc, argv, "di:" )) != EOF ) {
- X switch( c ) {
- X case 'd':
- X debug++;
- X break;
- X case 'i':
- X interface = optarg;
- X break;
- X default:
- X errs++;
- X }
- X }
- X if( errs > 0 )
- X exit( 1 );
- X
- X s = nit_open( interface, ETHERTYPE_CTP, localaddr, 1 );
- X if( s < 0 )
- X exit( 1 );
- X
- X printf("%s address ", interface );
- X petaddr( localaddr );
- X puts( "" );
- X if( !debug ) {
- X int i;
- X
- X i = fork();
- X if( i < 0 ) {
- X perror( "fork" );
- X exit( 1 );
- X }
- X else if( i != 0 )
- X exit( 0 );
- X
- X for( i = getdtablesize() - 1; i >= 0; i-- )
- X if( i != s )
- X close( i );
- X open( "/", 0 );
- X dup( 0 );
- X dup( 0 );
- X if( (i = open( "/dev/tty", 0)) >= 0 ) {
- X ioctl( i, TIOCNOTTY, 0 );
- X close( i );
- X }
- X }
- X
- X nit_loop( s, nit_input ); /* never returns */
- X} /* main */
- X
- X/****************************************************************/
- X
- Xvoid
- Xnit_input( s, nh )
- X int s;
- X struct nit_hdr *nh;
- X{
- X int l;
- X struct packet *pp;
- X u_char *p2, *p3;
- X short f, skip;
- X int len, l2;
- X
- X l = nh->nh_datalen;
- X pp = (struct packet *) (((u_char *)nh) + sizeof( struct nit_hdr ));
- X
- X if( !etcmp( pp->p_dst, bcast ) &&
- X !etcmp( pp->p_dst, mcast ) &&
- X !etcmp( pp->p_dst, localaddr ) )
- X return;
- X
- X p2 = (u_char *) pp->p_data;
- X skip = CTP_SHORT(p2);
- X
- X if( skip & 1 )
- X return; /* skip must not be odd */
- X
- X p3 = p2 + skip + 2; /* point to data (skip skip!) */
- X len = l - 14 - skip - 2; /* length of data */
- X
- X if( debug )
- X printf("CTP skip %d.\n", skip );
- X if( len < 2 )
- X return;
- X
- X f = CTP_SHORT( p3 ); /* get function */
- X p3 += 2; /* advance past function */
- X len -= 2; /* account for function length */
- X switch( f ) {
- X case CTP_REP: /* reply */
- X /* we're a server! */
- X break;
- X
- X case CTP_FWD: /* forward */
- X if( len < 6 ) {
- X if( debug )
- X printf("Too little data for FORWARD packet\n");
- X return;
- X }
- X if( debug ) {
- X printf(" FORWARD to: ");
- X petaddr( p3 ); /* print ether addr */
- X puts("");
- X }
- X if( *p3 & 0x01 ) {
- X if( debug )
- X printf("will not forward to multicast/broadcast\n");
- X return;
- X }
- X skip += 6 + 2; /* skip function and address */
- X * ((u_short *)p2) = SSWAP( skip );
- X bcopy( localaddr, pp->p_src, sizeof( pp->p_src ) );
- X bcopy( p3, pp->p_dst, sizeof( pp->p_dst ) );
- X if( nit_output( s, pp, l ) < 0 )
- X perror( "nit output" );
- X break;
- X
- X default:
- X if( debug )
- X printf(" fncn %d.\n", f );
- X break;
- X }
- X}
- END_OF_ctpd.c
- if test 3465 -ne `wc -c <ctpd.c`; then
- echo shar: \"ctpd.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f dump.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"dump.c\"
- else
- echo shar: Extracting \"dump.c\" \(2113 characters\)
- sed "s/^X//" >dump.c <<'END_OF_dump.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X/*
- X * dump.c -- dump ether traffic
- X * Phil Budne @ BU/DSG
- X *
- X */
- X
- X# include <sys/types.h>
- X# include <sys/time.h>
- X# include <net/nit.h>
- X# include <stdio.h>
- X
- Xu_char localaddr[ 6 ];
- Xint count = -1;
- Xint promisc = 1;
- Xchar ibuf[100];
- Xchar *interface = ibuf;
- X
- Xextern int nit_snaplen;
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X extern char *optarg;
- X extern int optind, opterr;
- X int s, c, errs, len;
- X void nit_input(); /* forward */
- X
- X errs = 0;
- X len = -1;
- X while( (c = getopt( argc, argv, "c:i:l:p" )) != EOF ) {
- X switch( c ) {
- X case 'c':
- X count = atoi( optarg );
- X break;
- X case 'i':
- X interface = optarg;
- X break;
- X case 'l':
- X len = atoi( optarg );
- X break;
- X case 'p':
- X promisc ^= 1;
- X break;
- X default:
- X errs++;
- X }
- X }
- X if( errs > 0 )
- X exit( 1 );
- X
- X if( len > 0 )
- X nit_snaplen = len;
- X
- X s = nit_open( interface, NT_ALLTYPES, localaddr, promisc );
- X printf(" %s address ", interface );
- X petaddr( localaddr );
- X puts( "" );
- X
- X nit_loop( s, nit_input ); /* never returns */
- X} /* main */
- X
- X/****************************************************************/
- X
- Xvoid
- Xnit_input( s, nh )
- X int s;
- X struct nit_hdr *nh;
- X{
- X int l, l2;
- X u_char *pp;
- X
- X l = nh->nh_datalen; /* wirelen? */
- X pp = ((u_char *)nh) + sizeof( struct nit_hdr );
- X
- X while( l > 0 ) {
- X l2 = l;
- X if( l2 > 32 )
- X l2 = 32;
- X pbytes( pp, l2 );
- X puts("");
- X pp += l2;
- X l -= l2;
- X }
- X puts("");
- X
- X if( count > 0 )
- X if( --count == 0 )
- X exit( 0 );
- X
- X}
- X
- Xpbytes( p, c )
- X register u_char *p;
- X register int c;
- X{
- X while( c-- > 0 )
- X puthex( *p++ & 0xff );
- X}
- END_OF_dump.c
- if test 2113 -ne `wc -c <dump.c`; then
- echo shar: \"dump.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f ether-prot.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"ether-prot.h\"
- else
- echo shar: Extracting \"ether-prot.h\" \(2308 characters\)
- sed "s/^X//" >ether-prot.h <<'END_OF_ether-prot.h'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X Ethernet protocol types
- X
- XThe Ethernet TYPE field contains a hexadecimal number which can be
- Xinterpreted to yield a symbolic Ethernet protocol type name. A table of
- Xsome of the major Ethernet protocol types and their descriptions follows:
- X
- XHexadecimal Description
- X
- X0x0200 Xerox PUP
- X0x0201 PUP Address Trans.
- X0x0600 Xerox XNS IDP
- X0x0800 DoD IP
- X0x0801 X.75 Internet
- X0x0802 NBS Internet
- X0x0803 ECMA Internet
- X0x0804 Chaosnet
- X0x0805 X.25 Level 3
- X0x0806 ARP
- X0x0807 XNS Compatability
- X0x081C Symbolics Private
- X0x0a00 Xerox 802.3 PUP
- X0x0a01 PUP 802.3 Address Trans.
- X0x1000 Berkeley trailer
- X0x1001 IP_trailer_1_block
- X0x1002 IP_trailer_2_blocks
- X0x1003 IP_trailer_3_blocks
- X0x1004 IP_trailer_4_blocks
- X0x1005 IP_trailer_5_blocks
- X0x1006 IP_trailer_6_blocks
- X0x1007 IP_trailer_7_blocks
- X0x1008 IP_trailer_8_blocks
- X0x1009 IP_trailer_9_blocks
- X0x100a IP_trailer_10_blocks
- X0x100b IP_trailer_11_blocks
- X0x100c IP_trailer_12_blocks
- X0x100d IP_trailer_13_blocks
- X0x100e IP_trailer_14_blocks
- X0x100f IP_trailer_15_blocks
- X0x1600 VALID
- X0x5208 BBN Simnet
- X0x6000 DECNet0
- X0x6001 DEC MOP Dump/Load
- X0x6002 DEC MOP Remote Console
- X0x6003 DEC DECnet Routing
- X0x6004 DEC LAT
- X0x6005 DEC DECNet Diagnostics
- X0x6006 DEC DECNet SCA
- X0x6007 DEC DECNet7
- X0x8003 Cronus VLN
- X0x8004 Cronus Direct
- X0x8005 HP Probe
- X0x8006 Nestar
- X0x8010 Excelan
- X0x8013 SGI diagnostic type
- X0x8014 SGI network games
- X0x8015 SGI reserved type
- X0x8016 SGI `bounce server'
- X0x8035 Reverse ARP
- X0x8038 DEC LANBridge
- X0x805b Stanford V Kernel experimental
- X0x805c Stanford V Kernel production
- X0x807c Merit Internodal
- X0x8080 VitaLink bridge
- X0x809b Appletalk
- X0x80de TRFS (Integrated Solutions Transparent Remote File System)
- X0x80f3 Appletalk ARP
- X0x9000 Loopback
- X0x9001 Bridge bridge
- X0x9002 Bridge terminal
- X0xff00 BBN VITAL LANBridge
- END_OF_ether-prot.h
- if test 2308 -ne `wc -c <ether-prot.h`; then
- echo shar: \"ether-prot.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f hetoea.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"hetoea.c\"
- else
- echo shar: Extracting \"hetoea.c\" \(1144 characters\)
- sed "s/^X//" >hetoea.c <<'END_OF_hetoea.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X# include <netdb.h> /* for hostent */
- X# include <sys/types.h> /* for socket.h */
- X# include <sys/socket.h> /* AF_INET */
- X
- Xhostenttoea( he, ea )
- X struct hostent *he;
- X char *ea;
- X{
- X char **ap;
- X
- X if( ether_hostton( he->h_name, ea ) == 0 ) /* try official name */
- X return( 1 ); /* in ethers file */
- X
- X for( ap = he->h_aliases; *ap != NULL; ap++ )
- X if( ether_hostton( *ap, ea ) == 0 ) /* try aliases in ethers file */
- X return( 1 );
- X
- X if( he->h_addrtype == AF_INET ) /* is inet host?? */
- X if( iptoea( he->h_addr, ea ) ) /* try to convert to ea */
- X return( 1 );
- X
- X return( 0 );
- X} /* hostenttoea */
- END_OF_hetoea.c
- if test 1144 -ne `wc -c <hetoea.c`; then
- echo shar: \"hetoea.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f htoea.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"htoea.c\"
- else
- echo shar: Extracting \"htoea.c\" \(1908 characters\)
- sed "s/^X//" >htoea.c <<'END_OF_htoea.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X# include <netdb.h> /* for hostent */
- X# include <sys/types.h> /* for socket.h */
- X# include <sys/socket.h> /* AF_INET */
- X# include <ctype.h>
- X
- Xhtoea( h, ea )
- X char *h, *ea;
- X{
- X struct hostent *he;
- X int tempea[6], tempip;
- X int i;
- X
- X if( sscanf( h, "%x-%x-%x-%x-%x-%x", /* Xerox/DEC/Intel format? */
- X &tempea[0], &tempea[1], &tempea[2],
- X &tempea[3], &tempea[4], &tempea[5] ) == 6 ||
- X sscanf( h, "%x:%x:%x:%x:%x:%x", /* BSD format? */
- X &tempea[0], &tempea[1], &tempea[2],
- X &tempea[3], &tempea[4], &tempea[5] ) == 6 ) {
- X for( i = 0; i < 6; i++ )
- X *ea++ = tempea[i] & 0xff; /* complain if gt 8 bits? */
- X return( 1 );
- X }
- X
- X if( isalpha( h[0] ) ) {
- X if( ether_hostton( h, ea ) == 0 ) /* look up in /etc/ethers */
- X return( 1 ); /* we win! */
- X
- X if( (he = gethostbyname( h )) != NULL ) { /* get host ent */
- X if( hostenttoea( he, ea ) ) /* look up name in /etc/hosts */
- X return( 1 );
- X }
- X
- X if( strcmp( h, "BCAST" ) == 0 ) { /* do last? */
- X for( i = 0; i < 6; i++ )
- X *ea++ = 0xff;
- X return( 1 );
- X }
- X }
- X
- X /* @@ handle 96 hex digits, 48hex-48hex */
- X
- X /* after hex format */
- X if( (tempip = inet_addr( h )) != 0) { /* ip octets? */
- X if( iptoea( &tempip, ea ) )
- X return( 1 );
- X
- X if( (he = gethostbyaddr( &tempip, 4, AF_INET )) != NULL )
- X if( hostenttoea( he, ea ) )
- X return( 1 );
- X }
- X return( 0 );
- X}
- END_OF_htoea.c
- if test 1908 -ne `wc -c <htoea.c`; then
- echo shar: \"htoea.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f iptoea.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"iptoea.c\"
- else
- echo shar: Extracting \"iptoea.c\" \(1779 characters\)
- sed "s/^X//" >iptoea.c <<'END_OF_iptoea.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <sys/types.h> /* for socket.h */
- X# include <sys/socket.h> /* sockaddr */
- X# include <net/if.h> /* arpreq */
- X# include <sys/ioctl.h>
- X# include <sys/errno.h>
- X# include <netinet/in.h> /* sockaddr_in */
- Xextern int errno;
- X
- Xiptoea( ip, ea )
- X long *ip;
- X char *ea;
- X{
- X struct sockaddr_in *sin;
- X struct arpreq arp;
- X int s, i;
- X
- X if( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 )
- X return( 0 );
- X
- X arp.arp_ha.sa_family = AF_UNSPEC;
- X arp.arp_pa.sa_family = AF_INET;
- X sin = (struct sockaddr_in *) &arp.arp_pa;
- X bcopy( ip, &sin->sin_addr, sizeof( *ip ) );
- X
- X /* force arp */
- X sin->sin_port = 1; /* seems unlikely */
- X if( sendto( s, &s, 0, 0, sin, sizeof( struct sockaddr_in ) ) < 0 )
- X perror( "sendto" ); /* ??ignore */
- X
- X for( i = 0; i < 10; i++ ) {
- X if( ioctl( s, SIOCGARP, &arp ) < 0 ) {
- X if( errno != ENXIO ) { /* not does not exist? */
- X perror( "ioctl" ); /* whine */
- X break; /* leave while */
- X }
- X i++; /* penalize for no entry yet */
- X /* (wait longer if incomplete found) */
- X }
- X else if( arp.arp_flags & ATF_COM ) { /* complete? */
- X bcopy( arp.arp_ha.sa_data, ea, 6 );
- X close( s );
- X return( 1 );
- X } /* complete */
- X usleep( 100000 ); /* .1 sec */
- X } /* for */
- X
- X close( s );
- X return( 0 );
- X}
- END_OF_iptoea.c
- if test 1779 -ne `wc -c <iptoea.c`; then
- echo shar: \"iptoea.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f mfgr.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"mfgr.h\"
- else
- echo shar: Extracting \"mfgr.h\" \(598 characters\)
- sed "s/^X//" >mfgr.h <<'END_OF_mfgr.h'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- Xtypedef struct mfgr {
- X unsigned long mf_code;
- X char *mf_name;
- X} MFGR;
- X
- Xextern MFGR mfgrs[];
- END_OF_mfgr.h
- if test 598 -ne `wc -c <mfgr.h`; then
- echo shar: \"mfgr.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f mfgrs.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"mfgrs.c\"
- else
- echo shar: Extracting \"mfgrs.c\" \(3024 characters\)
- sed "s/^X//" >mfgrs.c <<'END_OF_mfgrs.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include "mfgr.h"
- X
- XMFGR mfgrs[] = {
- X 0x00000c, "W.D.", /* Western Digital */
- X 0x00002a, "TRW",
- X 0x00005a, "S&Koch",
- X 0x000093, "Proteon",
- X 0x000093, "Ameristar", /* Ameristar Tech. */
- X 0x0000aa, "Xerox",
- X 0x0000c0, "W.D.", /* ? */
- X 0x0000dd, "Gould",
- X 0x000102, "BBN", /* unofficial */
- X 0x001700, "Kabel",
- X 0x00dd00, "U-B", /* seen in PC/RT */
- X 0x00dd01, "U-B", /* seen in IBM 8232 (2273A board) */
- X 0x020701, "Interlan", /* (UNIBUS/QBUS), Apollo */
- X 0x020406, "BBN", /* unofficial */
- X 0x02608c, "3Com", /* (PC/Imagen/Valid) */
- X 0x02cf1f, "CMC", /* (Masscomp/SGI) */
- X 0x080002, "Bridge",
- X 0x080005, "Symbolics",
- X 0x080008, "BBN",
- X 0x080009, "H-P",
- X 0x080010, "AT+T", /* ?? */
- X 0x080014, "Excelan", /* (BBN Butterfly/Masscomp/Iris) */
- X 0x08001a, "DG",
- X 0x08001b, "DG",
- X 0x08001e, "Apollo",
- X 0x080020, "Sun",
- X 0x080028, "TI", /* TI Explorer */
- X 0x08002b, "DEC", /* UNIBUS/QBUS/VAX/LANBridge */
- X /* DEUNA, DEQNA, DELUA */
- X
- X 0x080045, "???",
- X 0x080047, "Sequent",
- X 0x080049, "Univation",
- X 0x08004c, "Encore",
- X 0x08004e, "BICC",
- X 0x080068, "Ridge",
- X 0x080069, "SGI", /* Silicon Graphics */
- X 0x08006e, "Excelan",
- X 0x08007c, "Vitalink", /* TransLAN III */
- X 0x080089, "Kinetics",
- X 0x08008b, "Pyramid",
- X 0x08008d, "XyVision",
- X 0x090090, "H-P", /* MULTICAST */
- X 0x09002b, "LanBridge", /* MULTICAST */
- X /* 01-00-00 LanBridge Copy */
- X /* 01-00-01 LanBridge Hello (1/sec)*/
- X
- X 0x800010, "AT+T", /* 3b2 3Bnet card */
- X 0xaa0003, "DEC", /* DEUNA/KLNI */
- X 0xaa0004, "DECNET", /* logical address */
- X
- X 0xab0000, "DEC multcast", /* MULTICAST */
- X /*
- X * lower part
- X * 01-00-00 DL-MOP Dump/Load assist
- X * 02-00-00 RE-MOP Remote console sys id (1 every 8-10min)
- X * from LanBridge, DEUNA, DELUA, DEQNA*
- X * 03-00-00 DECnet phase IV end node hello (1 every 15 sec)
- X * 04-00-00 DECnet phase IV router hello (1 every 15 sec)
- X *
- X */
- X
- X 0xab0001, "DEC ??", /* reserved MULTICAST */
- X 0xab0002, "DEC ??", /* reserved MULTICAST */
- X
- X 0xab0003, "LAT", /* MULTICAST */
- X /* low octets? */
- X
- X 0xab0004, "DEC", /* reserved MULTICAST */
- X /*
- X * 00-00-00 thru
- X * ff-ff-ff reserved for customer??
- X * 01-xx-yy LAVC Cluster group yy??
- X */
- X 0xc00000, "Western Digital?", /* ?? */
- X 0xcf0000, "CTP", /* MULTICAST */
- X 0, ""
- X};
- X
- Xint nmfgrs = ( sizeof( mfgrs ) / sizeof( MFGR ) ) - 1;
- END_OF_mfgrs.c
- if test 3024 -ne `wc -c <mfgrs.c`; then
- echo shar: \"mfgrs.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f ns.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"ns.c\"
- else
- echo shar: Extracting \"ns.c\" \(3818 characters\)
- sed "s/^X//" >ns.c <<'END_OF_ns.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X/*
- X * ns.c -- name server crock
- X * Phil Budne @ Boston U / Distributed Systems
- X * September 1986
- X */
- X
- X# include <stdio.h>
- X# include <netdb.h>
- X# include <sys/types.h>
- X# include <sys/socket.h>
- X# include <netinet/in.h>
- X# include <arpa/inet.h>
- X# include <signal.h>
- X# include <setjmp.h>
- X
- X# ifndef DEBUGF
- X# define DEBUGF 0 /* non-zero to debug */
- X# endif /* DEBUGF not defined */
- X
- Xextern char *malloc(), *strcpy();
- X
- X# define TABLE_SIZE 200
- Xstruct table {
- X unsigned long table_addr;
- X char *table_name;
- X} table[ TABLE_SIZE ];
- Xint table_pointer = 0;
- X
- X# define NS_ADDR 0x80c51428 /* bu-it-itnet */
- X# define NS_PORT 53
- X
- Xchar *jname; /* argv[0] */
- X
- Xstruct domain {
- X short id, op, qc, ac, nc, dc;
- X char qa[1];
- X};
- X
- Xstruct qsuf {
- X short type, class;
- X};
- X
- X# define cat(t,f){register int l = strlen(f);*t++ = l; strcpy(t,f);t+=l;}
- X
- Xint s;
- Xinited = 0;
- X
- Xchar *ns_lookup( addr )
- Xunsigned long addr;
- X{
- X struct sockaddr_in sin;
- X char buf[ 128 ]; /* short query! */
- X register struct domain *dp;
- X register char *p;
- X register struct qsuf *q;
- X char name[ 100 ];
- X
- X if( !inited && (s = socket( AF_INET, SOCK_DGRAM, 0)) < 0 )
- X return NULL;
- X inited = 1;
- X
- X sin.sin_family = AF_INET;
- X sin.sin_port = htons( NS_PORT );
- X sin.sin_addr.s_addr = htonl( NS_ADDR );
- X
- X dp = (struct domain *) buf;
- X dp->id = 0;
- X dp->op = htons( 0400 ); /* please recurse */
- X dp->qc = htons( 1 ); /* just one question... */
- X dp->ac = dp->nc = dp->dc = 0;
- X p = dp->qa;
- X
- X sprintf( name, "%d", addr & 255 );
- X cat(p, name );
- X sprintf( name, "%d", (addr >> 8) & 255 );
- X cat(p, name );
- X sprintf( name, "%d", (addr >> 16) & 255 );
- X cat(p, name );
- X sprintf( name, "%d", (addr >> 24) & 255 );
- X cat(p, name );
- X cat(p, "in-addr" );
- X cat(p, "arpa" );
- X *p++ = '\0';
- X
- X q = (struct qsuf *) p;
- X q->type = htons( 12 ); /* domain name pointer */
- X q->class = htons( 1 ); /* the internet */
- X p += sizeof( struct qsuf );
- X
- X# if DEBUGF
- X printf( "to %s port %d\n",
- X inet_ntoa( sin.sin_addr.s_addr ), ntohs( sin.sin_port ) );
- X# endif /* DEBUGF */
- X
- X /* TIMEOUT!!!! */
- X if( sendto( s, buf, p - buf, 0, &sin, sizeof( sin ) ) < 0 ||
- X read( s, buf, sizeof( buf ) ) < 0 ) {
- X close( s );
- X inited = 0;
- X return NULL;
- X }
- X
- X if( ntohs( dp->op ) & 017 || ntohs( dp->ac ) <= 0 )
- X return NULL;
- X else {
- X while( *p != '\0' )
- X if( *p & 0300 ) /* compressed? */
- X *++p = '\0';
- X else
- X p += *p + 1;
- X p += 10 + 1; /* rsrc record heading len */
- X
- X
- X name[0] = '\0';
- X while( *p != '\0' ) {
- X if( *p & 0300 ) /* compressed? */
- X p = buf + (ntohs( * (int *)p ) & 037777);
- X else {
- X strncat( name, p+1, *p );
- X strcat( name, "." );
- X p += *p + 1;
- X }
- X }
- X
- X if( strlen( name ) )
- X name[ strlen( name ) - 1 ] = '\0';
- X
- X return( strcpy( malloc( strlen( name ) + 1 ), name ) );
- X }
- X} /* ns_lookup */
- X
- Xchar *lookup_name( addr )
- X unsigned long addr;
- X{
- X register int i;
- X char *n;
- X
- X for( i = 0; i < table_pointer; i++ )
- X if( addr == table[ i ].table_addr )
- X return( table[ i ].table_name );
- X
- X n = ns_lookup( addr );
- X
- X if( table_pointer == TABLE_SIZE - 1 )
- X return n;
- X
- X/* if( n == NULL ) return NULL; /* cache failures too! */
- X
- X table[ table_pointer ].table_name = n;
- X table[ table_pointer++ ].table_addr = addr;
- X return( n );
- X}
- X
- END_OF_ns.c
- if test 3818 -ne `wc -c <ns.c`; then
- echo shar: \"ns.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f pbytes.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"pbytes.c\"
- else
- echo shar: Extracting \"pbytes.c\" \(601 characters\)
- sed "s/^X//" >pbytes.c <<'END_OF_pbytes.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X
- Xpbytes( p, c )
- X unsigned char *p;
- X int c;
- X{
- X while( c-- > 0 )
- X puthex( (unsigned)*p++ );
- X}
- END_OF_pbytes.c
- if test 601 -ne `wc -c <pbytes.c`; then
- echo shar: \"pbytes.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f petaddr.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"petaddr.c\"
- else
- echo shar: Extracting \"petaddr.c\" \(880 characters\)
- sed "s/^X//" >petaddr.c <<'END_OF_petaddr.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X
- Xpetaddr( a ) /* print ether addr */
- X register unsigned char *a;
- X{
- X puthex( (unsigned)a[0] );
- X putchar('-');
- X puthex( (unsigned)a[1] );
- X putchar('-');
- X puthex( (unsigned)a[2] );
- X putchar('-');
- X puthex( (unsigned)a[3] );
- X putchar('-');
- X puthex( (unsigned)a[4] );
- X putchar('-');
- X puthex( (unsigned)a[5] );
- X
- X} /* petaddr */
- END_OF_petaddr.c
- if test 880 -ne `wc -c <petaddr.c`; then
- echo shar: \"petaddr.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f petaddrm.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"petaddrm.c\"
- else
- echo shar: Extracting \"petaddrm.c\" \(651 characters\)
- sed "s/^X//" >petaddrm.c <<'END_OF_petaddrm.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X
- Xpetaddrm( ea )
- X char *ea;
- X{
- X petaddr( ea );
- X putchar( ' ' );
- X putchar( '(' );
- X petmf( ea );
- X putchar( ')' );
- X}
- X
- END_OF_petaddrm.c
- if test 651 -ne `wc -c <petaddrm.c`; then
- echo shar: \"petaddrm.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f petmf.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"petmf.c\"
- else
- echo shar: Extracting \"petmf.c\" \(1301 characters\)
- sed "s/^X//" >petmf.c <<'END_OF_petmf.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X# include "mfgr.h"
- X
- Xpetmf( a ) /* print ether mfgr name */
- X register unsigned char *a;
- X{
- X long mfc;
- X register MFGR *mf;
- X
- X mfc = (((a[0] << 8) + a[1]) << 8) + a[2]; /* top 24 bits */
- X
- X /* check for IEEE "local" bit??? @@ */
- X if( *a & 1 ) { /* logical address? */
- X register int broadcast, i;
- X
- X broadcast = 1; /* set true */
- X for( i = 0; broadcast && i < 6; i++ )
- X if( a[i] != 0xff )
- X broadcast = 0;
- X
- X if( broadcast )
- X printf( "broadcast" );
- X else
- X printf( "%smulticast", "" /* lookup registry of mfc */ );
- X return;
- X } /* logical */
- X
- X /* @@TLU */
- X for( mf = mfgrs; mf->mf_code != 0; mf++ )
- X if( mf->mf_code == mfc ) {
- X printf( "%s", mf->mf_name );
- X return;
- X }
- X else if( mf->mf_code > mfc )
- X break;
- X
- X printf( "unknown");
- X}
- END_OF_petmf.c
- if test 1301 -ne `wc -c <petmf.c`; then
- echo shar: \"petmf.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f pipaddr.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"pipaddr.c\"
- else
- echo shar: Extracting \"pipaddr.c\" \(840 characters\)
- sed "s/^X//" >pipaddr.c <<'END_OF_pipaddr.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include "packet.h"
- Xint use_nameserver = 1;
- X# define NULL ((char *)0)
- X
- Xpipaddr( f, i )
- X int f;
- X ip_addr i;
- X{
- X char *n, *lookup_name();
- X if( f && use_nameserver && (n = lookup_name( i )) != NULL )
- X printf("%s", n );
- X else
- X printf("%d.%d.%d.%d",
- X (i >> 24) & 255,
- X (i >> 16) & 255,
- X (i >> 8) & 255,
- X i & 255 );
- X}
- X
- END_OF_pipaddr.c
- if test 840 -ne `wc -c <pipaddr.c`; then
- echo shar: \"pipaddr.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f protocol.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"protocol.h\"
- else
- echo shar: Extracting \"protocol.h\" \(4935 characters\)
- sed "s/^X//" >protocol.h <<'END_OF_protocol.h'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- Xstruct protocol {
- X unsigned short pr_type;
- X char *pr_short;
- X char *pr_name;
- X} protocols[] = {
- X 0x0200, "PUP", "Xerox PUP", /* 802.3 length!! */
- X 0x0201, "PUPAT", "Xerox PUP Addr. Trans.", /* 802.3 length!! */
- X 0x0600, "XNS", "Xerox NS (XNS) IDP",
- X 0x0800, "IP", "DoD IP",
- X 0x0801, "X.75", "X.75 Internet",
- X 0x0802, "NBS", "NBS Internet",
- X 0x0803, "ECMA", "ECMA Internet",
- X 0x0804, "Chaos", "Chaosnet",
- X 0x0805, "X.25", "X.25 Level 3",
- X 0x0806, "ARP", "Address Resolution Protocol (ARP)",
- X 0x0807, "XNScomp", "XNS Compatibility",
- X 0x081c, "Symbolics", "Symbolics Private",
- X 0x0888, "Xyplex", "Xyplex",
- X 0x0a00, "PUP2", "802.3 Xerox PUP",
- X 0x0a01, "PUPAT2", "802.3 PUP Address Translation",
- X 0x0bad, "Banyan", "Banyan Systems",
- X 0x1000, "TRAIL0", "Berkeley Trailer negotiation",
- X 0x1001, "TRAIL1", "Berkeley Trailer 1",
- X 0x1002, "TRAIL2", "Berkeley Trailer 2",
- X 0x1003, "TRAIL3", "Berkeley Trailer 3",
- X 0x1004, "TRAIL4", "Berkeley Trailer 4",
- X 0x1005, "TRAIL5", "Berkeley Trailer 5",
- X 0x1006, "TRAIL6", "Berkeley Trailer 6",
- X 0x1007, "TRAIL7", "Berkeley Trailer 7",
- X 0x1008, "TRAIL8", "Berkeley Trailer 8",
- X 0x1009, "TRAIL9", "Berkeley Trailer 9",
- X 0x100a, "TRAIL10", "Berkeley Trailer 10",
- X 0x100b, "TRAIL11", "Berkeley Trailer 11",
- X 0x100c, "TRAIL12", "Berkeley Trailer 12",
- X 0x100d, "TRAIL13", "Berkeley Trailer 13",
- X 0x100e, "TRAIL14", "Berkeley Trailer 14",
- X 0x100f, "TRAIL15", "Berkeley Trailer 15",
- X 0x1600, "VALID", "VALID",
- X 0x5208, "Simnet", "BBN Simnet Private",
- X 0x6000, "DEC XP", "DEC XP",
- X 0x6001, "DEC DL-MOP", "DEC Dump/Load Maintenance Operation Protocol",
- X 0x6002, "DEC RE-MOP", "DEC Remote Console Maintenance Operation",
- X 0x6003, "DECnet", "DECNET Phase IV",
- X 0x6004, "LAT", "DEC LAT - Local Area Transport",
- X 0x6005, "DEC diag?", "DEC interface initialization / diagnostics?",
- X 0x6006, "DEC customer", "DEC customer use",
- X 0x6007, "DEC SCA/LAVC", "DEC Sy. Comm. Arch. / Local Area VAX Cluster",
- X 0x6008, "DEC ??", "DEC unassigned",
- X 0x6009, "DEC ??", "DEC unassigned",
- X 0x7000, "UB/down", "Ungerman Bass download",
- X 0x7002, "UB/diag", "Ungerman Bass diag/loopback",
- X 0x7030, "Interlan", "Interlan 3010 test packet?",
- X 0x8003, "Cronus VLN", "Cronus VLN",
- X 0x8004, "Cronus Direct","Cronus Direct",
- X 0x8005, "HP Probe", "HP Probe protocol",
- X 0x8006, "Nestar", "Nestar",
- X 0x8008, "3BNET", "ATT 3BNET",
- X 0x8010, "Excelan", "Excelan",
- X 0x8013, "SGI diag", "Silicon Graphics diagnostic",
- X 0x8014, "SGI games", "Silicon Graphics network games",
- X 0x8015, "SGI reserved", "Silicon Graphics reserved type",
- X 0x8016, "SGI bounce", "Silicon Graphics XNS nameserver/bounce",
- X 0x8019, "Apollo", "Apollo DOMAIN",
- X 0x8035, "RARP", "Reverse ARP",
- X 0x8038, "DEBET", "DEC LanBridge (Debet) Management",
- X 0x8039, "DEC ?", "DEC unassigned",
- X 0x803a, "DEC ?", "DEC unassigned",
- X 0x803b, "DEC ?", "DEC unassigned",
- X 0x803c, "DEC ?", "DEC unassigned",
- X 0x803d, "DEC EEP", "DEC Ethernet Encryption Protocol",
- X 0x803e, "DEC ?", "DEC unassigned",
- X 0x803f, "DEC LTM", "DEC Lan Traffic Monitor",
- X 0x8040, "DEC ?", "DEC unassigned",
- X 0x8041, "DEC ?", "DEC unassigned",
- X 0x8042, "DEC ?", "DEC unassigned",
- X 0x805b, "exp. V", "Stanford V Kernel experimental",
- X 0x805c, "prod. V", "Stanford V Kernel production",
- X 0x807c, "Merit", "Merit Internodal",
- X 0x807d, "Vitalink ?", "Vitalink ?",
- X 0x807e, "Vitalink ?", "Vitalink ?",
- X 0x807f, "Vitalink ?", "Vitalink ?",
- X 0x8080, "Vitalink mgmt","Vitalink TransLAN III bridge mgmt",
- X 0x809b, "EtherTalk", "Ethernet/AppleTalk",
- X 0x809c, "EtherTalk Arp","Ethernet/AppleTalk Arp", /* ?? */
- X 0x80de, "TRFS", "Integrated Solutions Transparent Remote File System",
- X 0x80f3, "Appletalk ARP?","Appletalk ARP??", /* ?? */
- X 0x8107, "Symbolics", "Symbolics Private",
- X 0x8108, "Symbolics", "Symbolics Private",
- X 0x8109, "Symbolics", "Symbolics Private",
- X 0x8137, "Novell", "Novell", /* netware?? */
- X 0x9000, "CTP", "Configuration Test Protocol (CTP) Loopback",
- X 0x9001, "BRIDGEbridge", "BRIDGE bridge mgmt", /* XNS mgmt? */
- X 0x9002, "BRIDGEterm", "BRIDGE terminal server", /* TCP/IP mgmt? */
- X 0xff00, "VITAL", "BBN VITAL LANBridge cache wakeups",
- X 0, ""
- X};
- X
- X# define NPROTO (((sizeof protocols)/(sizeof( struct protocol )))-1)
- END_OF_protocol.h
- if test 4935 -ne `wc -c <protocol.h`; then
- echo shar: \"protocol.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f puthex.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"puthex.c\"
- else
- echo shar: Extracting \"puthex.c\" \(681 characters\)
- sed "s/^X//" >puthex.c <<'END_OF_puthex.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X
- Xputhex( i )
- X register unsigned i;
- X{
- X static char hecks[] = "0123456789ABCDEF";
- X putchar( hecks[ (i >> 4) & 0xf ] );
- X putchar( hecks[ i & 0xf ] );
- X}
- END_OF_puthex.c
- if test 681 -ne `wc -c <puthex.c`; then
- echo shar: \"puthex.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f samecount.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"samecount.c\"
- else
- echo shar: Extracting \"samecount.c\" \(812 characters\)
- sed "s/^X//" >samecount.c <<'END_OF_samecount.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- Xmain() {
- X char line[2][ 1000 ];
- X int i, j, c;
- X
- X i = 0;
- X c = 0;
- X while( gets( line[i] ) ) {
- X j = (i + 1) & 1;
- X if( strcmp( line[i], line[j] ) == 0 )
- X c++;
- X else if( c > 0 ) {
- X printf("%5d %s\n", c, line[j] );
- X c = 1;
- X }
- X i = j;
- X }
- X if( c > 0 )
- X printf("%5d %s\n", c, line[i] );
- X}
- END_OF_samecount.c
- if test 812 -ne `wc -c <samecount.c`; then
- echo shar: \"samecount.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f show.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"show.c\"
- else
- echo shar: Extracting \"show.c\" \(3211 characters\)
- sed "s/^X//" >show.c <<'END_OF_show.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X/*
- X * show.c -- show ctp traffic
- X * Phil Budne @ BU/DSG
- X *
- X * NOTE: user mode ctpd robs replies (?)
- X */
- X
- X# include <sys/types.h>
- X# include <sys/time.h>
- X# include <net/nit.h>
- X# include <stdio.h>
- X# include "ctp.h"
- X
- Xstruct packet {
- X u_char p_dst[ 6 ];
- X u_char p_src[ 6 ];
- X u_short p_type;
- X u_char p_data[ 2048 ];
- X};
- X
- Xu_char localaddr[ 6 ];
- Xint count = -1;
- Xint promisc = 1;
- Xchar *interface = "ie0";
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X extern char *optarg;
- X extern int optind, opterr;
- X int s, c, errs;
- X void nit_input(); /* forward */
- X
- X errs = 0;
- X while( (c = getopt( argc, argv, "c:i:p" )) != EOF ) {
- X switch( c ) {
- X case 'c':
- X count = atoi( optarg );
- X break;
- X case 'i':
- X interface = optarg;
- X break;
- X case 'p':
- X promisc ^= 1;
- X break;
- X default:
- X errs++;
- X }
- X }
- X if( errs > 0 )
- X exit( 1 );
- X
- X /*NT_ALLTYPES*/
- X s = nit_open( interface, ETHERTYPE_CTP, localaddr, promisc );
- X printf("%s address ", interface );
- X petaddr( localaddr );
- X puts( "" );
- X
- X nit_loop( s, nit_input ); /* never returns */
- X} /* main */
- X
- X/****************************************************************/
- X
- Xvoid
- Xnit_input( s, nh )
- X int s;
- X struct nit_hdr *nh;
- X{
- X int l;
- X struct packet *pp;
- X
- X u_char *p2;
- X short f, skip;
- X int len, l2;
- X
- X l = nh->nh_datalen;
- X pp = (struct packet *) (((u_char *)nh) + sizeof( struct nit_hdr ));
- X
- X printf("src ");
- X petaddr( pp->p_src );
- X printf(" dest ");
- X petaddr( pp->p_dst );
- X
- X p2 = (u_char *) pp->p_data;
- X skip = CTP_SHORT(p2);
- X
- X if( skip & 1 )
- X return; /* skip must not be odd */
- X
- X p2 += skip + 2; /* point to data (skip skip!) */
- X len = l - 14 - skip - 2; /* length of data */
- X
- X printf(" skip %d.\n", skip );
- X for( ; ; ) {
- X if( len < 2 )
- X return;
- X
- X f = CTP_SHORT( p2 ); /* get function */
- X p2 += 2; /* advance past function */
- X len -= 2; /* account for function length */
- X switch( f ) {
- X case CTP_REP: /* reply */
- X printf(" REPLY data: ");
- X goto break_for;
- X break;
- X
- X case CTP_FWD: /* forward */
- X if( len < 6 ) {
- X printf("Too little data for FORWARD packet\n");
- X return;
- X }
- X printf(" FORWARD to: ");
- X petaddr( p2 ); /* print ether addr */
- X puts("");
- X p2 += 6; /* advance data */
- X len -=6; /* account for len */
- X break;
- X
- X default:
- X printf(" fncn %d. data: ", f );
- X goto break_for;
- X }
- X }
- X break_for: ;
- X l2 = len;
- X if( l2 > 32 )
- X l2 = 32;
- X pbytes( p2, l2 );
- X if( len > 32 )
- X printf("...");
- X puts("");
- X
- X
- X if( count > 0 )
- X if( --count == 0 )
- X exit( 0 );
- X
- X}
- X
- Xpbytes( p, c )
- X u_char *p;
- X int c;
- X{
- X while( c-- > 0 )
- X printf("%02X", *p++ & 0xff );
- X}
- END_OF_show.c
- if test 3211 -ne `wc -c <show.c`; then
- echo shar: \"show.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f tab.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"tab.c\"
- else
- echo shar: Extracting \"tab.c\" \(3498 characters\)
- sed "s/^X//" >tab.c <<'END_OF_tab.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X# include <ctype.h>
- X# include "packet.h"
- X
- Xstruct hent {
- X union {
- X EA hd_ea;
- X short hd_type;
- X } h_data;
- X int h_cnt;
- X int h_inuse;
- X};
- X# define h_ea h_data.hd_ea
- X# define h_type h_data.hd_type
- X
- X# define HSIZE 1001
- Xstruct hent srchash[ HSIZE ];
- Xstruct hent dsthash[ HSIZE ];
- Xstruct hent typehash[ HSIZE ];
- Xint length[ 1520 ];
- X
- Xint count = 0;
- Xint pc;
- X
- Xmain() {
- X char line[ 4096 ];
- X register byte *pp;
- X register char *lp;
- X register int i;
- X
- X pc = 0;
- X pp = packet.p_bytes;
- X while( gets( line ) ) {
- X if( line[0] == ' ' || line[0] == '*' || line[0] == '\0' ) {
- X if( pc > 0 )
- X process();
- X pp = packet.p_bytes;
- X pc = 0;
- X continue;
- X }
- X
- X for( lp = line; *lp; lp++ ) {
- X if( isspace( *lp ) )
- X continue;
- X else if( isxdigit( *lp ) && isxdigit( lp[1] ) ) {
- X *pp++ = xval( *lp, lp[1] );
- X lp++;
- X pc++;
- X }
- X else
- X fprintf( stderr, "you lose: %s\n", lp );
- X }
- X }
- X if( pc > 0 )
- X process();
- X dump_ht_ea( "src", srchash, HSIZE );
- X dump_ht_ea( "dst", dsthash, HSIZE );
- X dump_ht_short( "type", typehash, HSIZE );
- X
- X for( i = 0; i < 1520; i++ )
- X if( length[i] > 0 )
- X printf("%4d %4d\n", i, length[i] );
- X}
- X
- Xprocess() {
- X register struct etherpacket *e = (struct etherpacket *) &packet;
- X u_short type;
- X
- X count++;
- X type = packet.p_ether.e_type;
- X/**
- X terpri();
- X printf("esrc: ");
- X petaddr( e->e_src );
- X putchar(' ');
- X putchar('/');
- X putchar(' ');
- X printf("edst: ");
- X petaddr( e->e_dst );
- X terpri();
- X printf("type=%02X-%02X len=%d\n",
- X (type >> 8) & 255,
- X type & 255,
- X pc );
- X**/
- X
- X ent_ea( srchash, e->e_src, HSIZE );
- X ent_ea( dsthash, e->e_dst, HSIZE );
- X
- X ent_short( typehash, type, HSIZE );
- X length[ pc ]++;
- X}
- X
- Xhash( p )
- X register unsigned char *p;
- X{
- X register h, h2, l;
- X l = 3;
- X h = 0;
- X while( l-- )
- X h = (h<<8) | *p++;
- X
- X l = 3;
- X h2 = 0;
- X while( l-- )
- X h2 = (h2<<8) | *p++;
- X
- X return( h ^ h2 );
- X}
- X
- Xent_ea( ht, ea, s )
- X struct hent *ht;
- X EA ea;
- X{
- X int h;
- X
- X h = hash( ea ) % s;
- X
- X while( ht[ h ].h_inuse && bcmp( ht[h].h_ea, ea, 6) != 0 )
- X h = (h + 101) % s;
- X
- X if( !ht[h].h_inuse ) {
- X bcopy( ea, ht[h].h_ea, 6 );
- X ht[h].h_inuse = 1;
- X }
- X
- X ht[h].h_cnt++;
- X}
- X
- Xent_short( ht, t, s )
- X struct hent *ht;
- X unsigned short t;
- X{
- X int h;
- X
- X h = t % s;
- X
- X while( ht[ h ].h_inuse && ht[h].h_type != t )
- X h = (h + 101) % s;
- X
- X if( !ht[h].h_inuse ) {
- X ht[h].h_type = t;
- X ht[h].h_inuse = 1;
- X }
- X
- X ht[h].h_cnt++;
- X}
- X
- Xdump_ht_ea( n, h, s )
- X char *n;
- X struct hent *h;
- X{
- X register int i;
- X puts( n );
- X for( i = 0; i < s; i++, h++ )
- X if( h->h_inuse ) {
- X printf(" %5d ", h->h_cnt );
- X petaddrm( h->h_ea );
- X terpri();
- X }
- X}
- X
- Xdump_ht_short( n, h, s )
- X char *n;
- X struct hent *h;
- X int s;
- X{
- X register int i;
- X
- X puts( n );
- X for( i = 0; i < s; i++, h++ )
- X if( h->h_inuse ) {
- X printf("%02X-%02X %d\n",
- X (h->h_type >> 8 ) & 255,
- X (h->h_type) & 255,
- X h->h_cnt );
- X }
- X}
- X
- END_OF_tab.c
- if test 3498 -ne `wc -c <tab.c`; then
- echo shar: \"tab.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f terpri.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"terpri.c\"
- else
- echo shar: Extracting \"terpri.c\" \(554 characters\)
- sed "s/^X//" >terpri.c <<'END_OF_terpri.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <stdio.h>
- X
- Xterpri() {
- X putchar('\n');
- X}
- X
- END_OF_terpri.c
- if test 554 -ne `wc -c <terpri.c`; then
- echo shar: \"terpri.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f test-htoea.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"test-htoea.c\"
- else
- echo shar: Extracting \"test-htoea.c\" \(844 characters\)
- sed "s/^X//" >test-htoea.c <<'END_OF_test-htoea.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- Xmain( argc, argv )
- X int argc;
- X char *argv[];
- X{
- X char ea[ 6 ];
- X
- X argc--;
- X argv++;
- X
- X if( argc < 1 )
- X puts("Usage: htoea {<name> | BCAST | <eaddr> | <ipaddr>}");
- X
- X while( argc-- > 0 ) {
- X printf("%s: ", argv[0] );
- X if( htoea( argv[0], ea ) ) {
- X petaddr( ea );
- X terpri();
- X }
- X else
- X puts("failed");
- X
- X argv++;
- X }
- X}
- END_OF_test-htoea.c
- if test 844 -ne `wc -c <test-htoea.c`; then
- echo shar: \"test-htoea.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f xval.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"xval.c\"
- else
- echo shar: Extracting \"xval.c\" \(784 characters\)
- sed "s/^X//" >xval.c <<'END_OF_xval.c'
- X/*
- X * Copyright (c) 1988 Philip L. Budne and The Trustees of Boston University
- X * All Rights Reserved
- X *
- X * Permission is granted to any individual or institution to use, copy,
- X * or redistribute this software so long as it is not sold for profit,
- X * provided that this notice and the original copyright notices are
- X * retained. Boston University makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X */
- X# include <ctype.h>
- X
- Xxval( c1, c2 )
- Xchar c1, c2;
- X{
- X int i;
- X i = (xnybble( c1 ) << 4) + xnybble( c2 );
- X return( i );
- X}
- X
- Xxnybble( c )
- Xchar c;
- X{
- X if( isdigit( c ) )
- X return( c - '0' );
- X else if( isupper( c ) )
- X return( c - 'A' + 10 );
- X else
- X return( c - 'a' + 10 );
- X}
- X
- END_OF_xval.c
- if test 784 -ne `wc -c <xval.c`; then
- echo shar: \"xval.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of archive 1 \(of 2\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-